<?php echo $javascript->link('scriptaculous-js-1.8.3/lib/prototype.js'); ?>
<?php echo $javascript->link('scriptaculous-js-1.8.3/src/scriptaculous.js'); ?>
<div class="manualmoves index">
	<table cellpadding="0" cellspacing="0" width="95%" class="tablenone2">
	<tr><td><blockquote>
	<div id="mmnew">
	<h2><?php __('Manualmoves NEW');?></h2>
	<table cellpadding="0" cellspacing="0" width="100%">
	<tr>
			<th width="100">&nbsp;Batch</th>
			<th width="120">&nbsp;Account</th>
			<th width="250">&nbsp;MAC</th>
			<th width="250">&nbsp;Added date</th>
			<th>&nbsp;Status</th>
			<th width="200">&nbsp;Actions</th>
	</tr>
	<?php
	$i = 0;
	$counter = 0;
	foreach ($mmnew as $new):
		$class = null;
		if ($i++ % 2 == 0) {
			$class = ' class="altrow"';
		}
		else {
			$class = ' class="altrow2"';
		}
		$div = "field".$counter;
	?>
	<tr<?php echo $class;?>>
	    <td>&nbsp;<?php echo $new['rhm']['run_id']; ?></td>
		<td>&nbsp;<?php echo $new['customer']['account_number']; ?></td>
		<td>&nbsp;<?php echo $new['mac']['mac']; ?></td>
		<td>&nbsp;<?php echo $new['manualmove']['date']; ?></td>
		<td>&nbsp;<?php echo $new['status']['statusdetail']; ?></td>
		<td><div id="<?php echo $div; ?>" name = "<?php echo $div; ?>">&nbsp;
		  <?php 
		  echo $ajax->link('Process', array('controller' => 'manualmoves', 'action' => 'solve', '?' => array('macid' => $new['mac']['id'], 'runid' =>  $new['rhm']['run_id'], 'div' => $div, 'mmid' => $new['manualmove']['id'])), array('update' => $div));
		  echo " - "; 
		  echo $ajax->link('Skip', array('controller' => 'manualmoves', 'action' => 'skip', '?' => array('macid' =>  $new['mac']['id'], 'div' => $div, 'mmid' => $new['manualmove']['id'])), array('update' => $div));
		  ?>
		</td>
	</tr>
	<?php $counter++; ?>
	<?php endforeach; ?>
	</table>
	<?php if($counter != 0){ ?>
	<form id="mmnew">
      <?php echo $ajax->submit('PREPARE all NEW Manual Moves for letter delivery', array('url'=> array('controller'=>'manualmoves', 'action'=>'mmnew'), 'update' => 'mmnew')); ?>
    </form>
    <?php } ?>
	<br />
	</div>
	</blockquote></td></tr>
	</table>

    <table cellpadding="0" cellspacing="0" width="95%" class="tablenone2">
	<tr><td><blockquote>
	<div id="mmrfld">
	<h2><?php __('Manualmoves READY FOR LETTER DELIVERY');?></h2>
	<table cellpadding="0" cellspacing="0" width="100%">
	<tr>
			<th width="100">&nbsp;Batch</th>
			<th width="120">&nbsp;Account</th>
			<th width="250">&nbsp;MAC</th>
			<th width="250">&nbsp;Last update</th>
			<th>&nbsp;Status</th>
	</tr>
	<?php
	$i = 0;
	$counter = 0;
	foreach ($mmrfld as $rfld):
		$class = null;
		if ($i++ % 2 == 0) {
			$class = ' class="altrow"';
		}
		else {
			$class = ' class="altrow2"';
		}
	?>
	<tr<?php echo $class;?>>
	    <td>&nbsp;<?php echo $rfld['rhm']['run_id']; ?></td>
		<td>&nbsp;<?php echo $rfld['customer']['account_number']; ?></td>
		<td>&nbsp;<?php echo $rfld['mac']['mac']; ?></td>
		<td>&nbsp;<?php echo $rfld['mms']['date']; ?></td>
		<td>&nbsp;<?php echo $rfld['status']['statusdetail']; ?></td>
	</tr>
	<?php $counter++; ?>
	<?php endforeach; ?>
	</table>
	<?php if($counter != 0){ ?>
	<?php echo $this->Html->link('Download customer data for letter delivery',array('controller' => 'manualmoves', 'action' => 'export1'));?><br>
	<?php echo $this->Html->link('Download customer data for Interactions',array('controller' => 'manualmoves', 'action' => 'export2'));?><br>
	<?php echo $this->Html->link('Download customer data for Modemhint',array('controller' => 'manualmoves', 'action' => 'export3'));?><br>
	<br /><br />
	<?php echo $ajax->form(array('type' => 'post','options' => array('model'=>'Manualmove','update' => 'mmrfld', 'url' => array('controller' => 'manualmoves','action' => 'mmrfld')))); ?> 
      Timeblocker till: 
      <select name="data[Manualmove][date]" id="ManualmoveDate" style="width:150px">
		<?php $time = mktime(6, 0, 0, date(m), date(d), date(Y)); ?>
		<option value="<?php echo $time+(1*86400); ?>"><?php echo date("d.m.Y",$time+(1*86400))." - ".date("D",$time+(1*86400)); ?></option>
		<option value="<?php echo $time+(2*86400); ?>"><?php echo date("d.m.Y",$time+(2*86400))." - ".date("D",$time+(2*86400)); ?></option>
		<option value="<?php echo $time+(3*86400); ?>" selected><?php echo date("d.m.Y",$time+(3*86400))." - ".date("D",$time+(3*86400)); ?></option>
		<option value="<?php echo $time+(4*86400); ?>"><?php echo date("d.m.Y",$time+(4*86400))." - ".date("D",$time+(4*86400)); ?></option>
		<option value="<?php echo $time+(5*86400); ?>"><?php echo date("d.m.Y",$time+(5*86400))." - ".date("D",$time+(5*86400)); ?></option>
		<option value="<?php echo $time+(6*86400); ?>"><?php echo date("d.m.Y",$time+(6*86400))." - ".date("D",$time+(6*86400)); ?></option>
		<option value="<?php echo $time+(7*86400); ?>"><?php echo date("d.m.Y",$time+(7*86400))." - ".date("D",$time+(7*86400)); ?></option>
		<option value="<?php echo $time+(8*86400); ?>"><?php echo date("d.m.Y",$time+(8*86400))." - ".date("D",$time+(8*86400)); ?></option>
		<option value="<?php echo $time+(9*86400); ?>"><?php echo date("d.m.Y",$time+(9*86400))." - ".date("D",$time+(9*86400)); ?></option>
		<option value="<?php echo $time+(10*86400); ?>"><?php echo date("d.m.Y",$time+(10*86400))." - ".date("D",$time+(10*86400)); ?></option>
	  </select>
      <input type="submit" value="SEND letters for all Manual Moves">
    </form>
    <?php } ?>
	<br />
	</div>
	</blockquote></td></tr>
	</table>
	
	<table cellpadding="0" cellspacing="0" width="95%" class="tablenone2">
	<tr><td><blockquote>
	<div id="mmwfld">
	<h2><?php __('Manualmoves WAITING FOR LETTER DELIVERY');?></h2>
	<table cellpadding="0" cellspacing="0" width="100%">
	<tr>
			<th width="100">&nbsp;Batch</th>
			<th width="120">&nbsp;Account</th>
			<th width="250">&nbsp;MAC</th>
			<th width="250">&nbsp;Blocked till</th>
			<th>&nbsp;Status</th>
	</tr>
	<?php
	$i = 0;
	foreach ($mmwfld as $wfld):
		$class = null;
		if ($i++ % 2 == 0) {
			$class = ' class="altrow"';
		}
		else {
			$class = ' class="altrow2"';
		}
	?>
	<tr<?php echo $class;?>>
	    <td>&nbsp;<?php echo $wfld['rhm']['run_id']; ?></td>
		<td>&nbsp;<?php echo $wfld['customer']['account_number']; ?></td>
		<td>&nbsp;<?php echo $wfld['mac']['mac']; ?></td>
		<td>&nbsp;<?php echo $wfld['mms']['date']; ?></td>
		<td>&nbsp;<?php echo $wfld['status']['statusdetail']; ?></td>
	</tr>
	<?php endforeach; ?>
	</table>
	</div>
	</blockquote></td></tr>
	</table>
	
	<table cellpadding="0" cellspacing="0" width="95%" class="tablenone2">
	<tr><td><blockquote>
	<div id="mmrfp">
	<h2><?php __('Manualmoves READY FOR PROCESSING');?></h2>
	<table cellpadding="0" cellspacing="0" width="100%">
	<tr>
			<th width="60">&nbsp;Batch</th>
			<th width="100">&nbsp;Account</th>
			<th width="250">&nbsp;MAC</th>
			<th width="250">&nbsp;Last update</th>
			<th>&nbsp;Status</th>
			<th width="260">&nbsp;Actions</th>
	</tr>
	<?php
	$i = 0;
	foreach ($mmrfp as $rfp):
		$class = null;
		if ($i++ % 2 == 0) {
			$class = ' class="altrow"';
		}
		else {
			$class = ' class="altrow2"';
		}
	?>
	<tr<?php echo $class;?>>
	    <td>&nbsp;<?php echo $rfp['rhm']['run_id']; ?></td>
		<td>&nbsp;<?php echo $rfp['customer']['account_number']; ?></td>
		<td>&nbsp;<?php echo $rfp['mac']['mac']; ?></td>
		<td>&nbsp;<?php echo $rfp['mms']['date']; ?></td>
		<td>&nbsp;<?php echo $rfp['status']['statusdetail']; ?></td>
		<td>&nbsp;
		<?php 
		  echo $ajax->link('Start processing', array('controller' => 'manualmoves', 'action' => 'mmrfp', '?' => array('mmid' => $rfp['manualmove']['id'])), array('update' => 'mmrfp')); 
		  echo " - ";
		  echo $ajax->link('Move2Blacklist', array('controller' => 'manualmoves', 'action' => 'move2blacklist', '?' => array('mmid' => $rfp['manualmove']['id'])), array('update' => 'mmrfp'));
		?>
		</td>
	</tr>
	<?php endforeach; ?>
	</table>
	</div>
	</blockquote></td></tr>
	</table>
	
	<table cellpadding="0" cellspacing="0" width="95%" class="tablenone2">
	<tr><td><blockquote>
	<div id="mmps">
	<h2><?php __('Manualmoves PROCESSING STARTED');?></h2>
	<table cellpadding="0" cellspacing="0" width="100%">
	<tr>
			<th width="100">&nbsp;Batch</th>
			<th width="120">&nbsp;Account</th>
			<th width="250">&nbsp;MAC</th>
			<th width="250">&nbsp;Last update</th>
			<th>&nbsp;Status</th>
			<th width="200">&nbsp;Actions</th>
	</tr>
	<?php
	$i = 0;
	$counter = 0;
	foreach ($mmps as $ps):
		$class = null;
		if ($i++ % 2 == 0) {
			$class = ' class="altrow"';
		}
		else {
			$class = ' class="altrow2"';
		}
	?>
	<tr<?php echo $class;?>>
	    <td>&nbsp;<?php echo $ps['rhm']['run_id']; ?></td>
		<td>&nbsp;<?php echo $ps['customer']['account_number']; ?></td>
		<td>&nbsp;<?php echo $ps['mac']['mac']; ?></td>
		<td>&nbsp;<?php echo $ps['mms']['date']; ?></td>
		<td>&nbsp;<?php echo $ps['status']['statusdetail']; ?></td>
		<td>&nbsp;<?php echo $ajax->link('Processing completed', array('controller' => 'manualmoves', 'action' => 'mmps', '?' => array('mmid' => $ps['manualmove']['id'])), array('update' => 'mmps')); ?></td>
	</tr>
	<?php endforeach; ?>
	</table>
	</div>
	</blockquote></td></tr>
	</table>
	
	<table cellpadding="0" cellspacing="0" width="95%" class="tablenone2">
	<tr><td><blockquote>
	<div id="mmrfsp">
	<h2><?php __('Manualmoves READY FOR SWAP PROCESSING');?></h2>
	<table cellpadding="0" cellspacing="0" width="100%">
	<tr>
			<th width="100">&nbsp;Batch</th>
			<th width="120">&nbsp;Account</th>
			<th width="250">&nbsp;MAC</th>
			<th width="250">&nbsp;Last update</th>
			<th>&nbsp;Status</th>
			<th width="200">&nbsp;Actions</th>
	</tr>
	<?php
	$i = 0;
	$counter2 = 0;
	foreach ($mmrfsp as $rfsp):
		$class = null;
		if ($i++ % 2 == 0) {
			$class = ' class="altrow"';
		}
		else {
			$class = ' class="altrow2"';
		}
		$div2 = "field2".$counter2;
	?>
	<tr<?php echo $class;?>>
	    <td>&nbsp;<?php echo $rfsp['rhm']['run_id']; ?></td>
		<td>&nbsp;<?php echo $rfsp['customer']['account_number']; ?></td>
		<td>&nbsp;<?php echo $rfsp['mac']['mac']; ?></td>
		<td>&nbsp;<?php echo $rfsp['mms']['date']; ?></td>
		<td>&nbsp;<?php echo $rfsp['status']['statusdetail']; ?></td>
		<td><div id="<?php echo $div2; ?>" name = "<?php echo $div2; ?>">&nbsp;
		  <?php 
		  echo $ajax->link('Process', array('controller' => 'manualmoves', 'action' => 'solve', '?' => array('macid' => $rfsp['mac']['id'], 'runid' =>  $rfsp['rhm']['run_id'], 'div' => $div2, 'mmid' => $rfsp['manualmove']['id'])), array('update' => $div2));
		  echo " - "; 
		  echo $ajax->link('Skip', array('controller' => 'manualmoves', 'action' => 'skip', '?' => array('macid' =>  $rfsp['mac']['id'], 'div' => $div2, 'mmid' => $rfsp['manualmove']['id'])), array('update' => $div2));
		  ?>
		</td>
	</tr>
	<?php $counter2++; ?>
	<?php endforeach; ?>
	</table>
	</div>
	</blockquote></td></tr>
	</table>
</div>